<?php

namespace app\store\controller\content;

use app\store\controller\Controller;
use app\store\model\Suggest as SuggestModel;
use think\Db;

/**
 * 文章管理控制器
 * Class article
 * @package app\store\controller\content
 */
class Suggest extends Controller
{
    /**
     * 投诉建议列表
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $model = new SuggestModel;
        $list = $model->getList();
        return $this->fetch('index', compact('list'));
    }


    /**
     * 删除投诉软删除
     * @param $id
     * @return array
     * @throws \think\exception\DbException
     */
    public function delete($id)
    {

        $where = "";
        $where['id'] = $id;
        $res = Db::name('suggest')->where($where)->update(['is_delete' => '1']);

        if (!$res) {
            return $this->renderError($model->getError() ?: '删除失败');
        }
        return $this->renderSuccess('删除成功');
//
//        $model = new SuggestModel;
//        // 详情
//        if (!$model->setDelete($id)) {
//            return $this->renderError($model->getError() ?: '删除失败');
//        }
//        return $this->renderSuccess('删除成功');
    }

}